﻿using System;
using System.Configuration;
using Newtonsoft.Json;

namespace XYAuto.MonitorData.Chitunion.RunTask.ConfigEntity
{
    public class MonitorDataSettings
    {
        public static ConfigEntityBase GetConfig()
        {
            var config = GetSetting("MonitorDataConfig");
            return JsonConvert.DeserializeObject<ConfigEntityBase>(config);
        }
        
        private static string GetSetting(string key)
        {
            try
            {
                return ConfigurationManager.AppSettings[key];
            }
            catch (Exception exception)
            {
                throw new Exception($"MonitorDataConfig AppSettings 请配置相关参数，{exception.Message},{exception.StackTrace ?? string.Empty}");
            }
        }
    }
}
